/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentanaOperacionesReserva.java
 *
 * Created on 25/06/2010, 11:52:48 AM
 */

package CapaGrafica;
import CapaLogica.GestionResort;
import CapaDatos.Reserva;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import CapaPersistencia.ControladorReserva;



/**
 *
 * @author Maria
 */
public class VentanaOperacionesReserva extends javax.swing.JFrame {
private ControladorReserva control = new ControladorReserva();
    /** Creates new form VentanaOperacionesReserva */
    public VentanaOperacionesReserva() {
        initComponents();
        mostrarTabla();
        this.setSize(600,500);
    }
    private void mostrarTabla() {
        DefaultTableModel dm = new DefaultTableModel();
        dm.addColumn("Cedula Cliente");
        dm.addColumn("ID Reserva");
        dm.addColumn("ID Habitacion");
        dm.addColumn("Fecha Inicio");
        dm.addColumn("Fecha Fin");
        dm.addColumn("Monto");
        ArrayList <Reserva> reservas = this.control.todasLasReservas();
        for (Reserva reserva : reservas) {
            Vector row = new Vector();
            GestionResort.getLasReservas().agregarElemento(reserva);
            row.add(reserva.getElCliente().getCedula());
            row.add(reserva.getID());
            row.add(reserva.getLaHabitacion().getID());
            row.add(reserva.getFechaInicio());
            row.add(reserva.getFechaFin());
            row.add(reserva.getMonto());
            dm.addRow(row);
        }
        this.tablaReservas.setModel(dm);


    }

    private void mostrarReserva(Integer idReserva) throws ParseException {
        Reserva reservaMostrar = this.control.buscarReserva(idReserva);
        this.sCedulaCliente.setText(reservaMostrar.getElCliente().getCedula());
        this.sIdReserva.setText(String.valueOf(reservaMostrar.getID()));
        this.sIdHabitacion.setText(reservaMostrar.getLaHabitacion().getID());
        this.sMonto.setText(String.valueOf(reservaMostrar.getMonto()));
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date fechaInicio = fechaFormato.parse(reservaMostrar.getFechaInicio());
        this.sFechaInicio.setDate(fechaInicio);
        java.util.Date fechaFin = fechaFormato.parse(reservaMostrar.getFechaInicio());
        this.sFechaFin.setDate(fechaFin);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        nIdHabitacion = new javax.swing.JTextField();
        nIdReserva = new javax.swing.JTextField();
        nCedulaCliente = new javax.swing.JTextField();
        nFechaInicio = new com.toedter.calendar.JDateChooser();
        nFechaFin = new com.toedter.calendar.JDateChooser();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jBAgregar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        sIdHabitacion = new javax.swing.JTextField();
        sIdReserva = new javax.swing.JTextField();
        sMonto = new javax.swing.JTextField();
        sCedulaCliente = new javax.swing.JTextField();
        sFechaInicio = new com.toedter.calendar.JDateChooser();
        sFechaFin = new com.toedter.calendar.JDateChooser();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaReservas = new javax.swing.JTable();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel16 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Modulo de Reservas");
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setLocationByPlatform(true);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel2.setBackground(new java.awt.Color(0, 102, 153));
        jPanel2.setName("jPanel2"); // NOI18N

        nIdHabitacion.setName("nIdHabitacion"); // NOI18N

        nIdReserva.setName("nIdReserva"); // NOI18N

        nCedulaCliente.setName("nCedulaCliente"); // NOI18N

        nFechaInicio.setName("nFechaInicio"); // NOI18N

        nFechaFin.setName("nFechaFin"); // NOI18N

        jLabel5.setText("ID Habitacion:");
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText("ID Reserva:");
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel8.setText("Cedula:");
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel10.setText("Fecha Entrada:");
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel12.setText("Fecha Salida:");
        jLabel12.setName("jLabel12"); // NOI18N

        jBAgregar.setText("Agregar");
        jBAgregar.setName("jBAgregar"); // NOI18N
        jBAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAgregarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel12)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel8))
                .addGap(12, 12, 12)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(nCedulaCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                    .addComponent(jBAgregar, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(nFechaFin, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(nFechaInicio, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(nIdReserva, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                    .addComponent(nIdHabitacion, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nIdHabitacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nIdReserva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(nCedulaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(nFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(nFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jBAgregar)
                .addContainerGap(34, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Agregar", jPanel2);

        jPanel1.setBackground(new java.awt.Color(0, 102, 153));
        jPanel1.setName("jPanel1"); // NOI18N

        sIdHabitacion.setName("sIdHabitacion"); // NOI18N

        sIdReserva.setName("sIdReserva"); // NOI18N

        sMonto.setName("sMonto"); // NOI18N

        sCedulaCliente.setName("sCedulaCliente"); // NOI18N

        sFechaInicio.setName("sFechaInicio"); // NOI18N

        sFechaFin.setName("sFechaFin"); // NOI18N

        jLabel1.setText("ID Habitacion:");
        jLabel1.setName("jLabel1"); // NOI18N

        jLabel2.setText("ID Reserva:");
        jLabel2.setName("jLabel2"); // NOI18N

        jLabel3.setText("Monto:");
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel4.setText("Cedula:");
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel9.setText("Fecha Entrada:");
        jLabel9.setName("jLabel9"); // NOI18N

        jLabel11.setText("Fecha Salida:");
        jLabel11.setName("jLabel11"); // NOI18N

        jButton2.setText("Actualizar");
        jButton2.setName("jButton2"); // NOI18N
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setText("Borrar");
        jButton3.setName("jButton3"); // NOI18N
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel9))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(sFechaInicio, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                            .addComponent(sCedulaCliente, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                            .addComponent(sMonto, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                            .addComponent(sIdReserva, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                            .addComponent(sIdHabitacion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(28, 28, 28)
                        .addComponent(sFechaFin, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
                .addComponent(jButton3)
                .addGap(46, 46, 46))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sIdHabitacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sIdReserva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sMonto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(sCedulaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel9)
                    .addComponent(sFechaInicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(sFechaFin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap())
        );

        jTabbedPane1.addTab("Actualizar o Eliminar", jPanel1);

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        tablaReservas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tablaReservas.setName("tablaReservas"); // NOI18N
        tablaReservas.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tablaReservasMouseReleased(evt);
            }
        });
        tablaReservas.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tablaReservasKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(tablaReservas);

        jScrollPane2.setViewportView(jScrollPane1);

        jSeparator1.setName("jSeparator1"); // NOI18N

        jLabel16.setFont(new java.awt.Font("Trebuchet MS", 0, 36));
        jLabel16.setForeground(new java.awt.Color(0, 51, 204));
        jLabel16.setText("i-Resort.");
        jLabel16.setName("jLabel16"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(316, Short.MAX_VALUE))
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 607, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 253, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAgregarActionPerformed
        boolean resultado = false;
        String cedulaCliente = this.nCedulaCliente.getText();
        Integer idReserva = Integer.parseInt(this.nIdReserva.getText());
        String idHabitacion = this.nIdHabitacion.getText();
        Double monto = 0.0;
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd/MM/yyyy");
        Date fechaInicio = this.nFechaInicio.getDate();
        String fechaBegin = fechaFormato.format(fechaInicio);
        Date fechaFin = this.nFechaFin.getDate();
        String fechaEnd = fechaFormato.format(fechaFin);

         if (GestionResort.getLasReservas().EstaLaReserva(idReserva)== false)
         {
        resultado = this.control.nuevaReserva(cedulaCliente, idHabitacion, fechaBegin, fechaEnd, idReserva, monto);
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Reserva " + idReserva + " agregado con exito", "Agregado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
      }
         else
               JOptionPane.showMessageDialog(null, "Operacion Fallida la Reserva con este ID se encuentra registrada ", "Error",
                    JOptionPane.ERROR_MESSAGE);// TODO add your handling code here:
    }//GEN-LAST:event_jBAgregarActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
      boolean resultado = this.control.eliminarReserva(Integer.parseInt(this.sIdReserva.getText()));
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Reserva " + this.sIdReserva.getText() + " borrada con exito", "Borrada",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        } // TODO add your handling code here:
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        boolean resultado = false;
        String cedulaCliente = this.sCedulaCliente.getText();
        Integer idReserva = Integer.parseInt(this.sIdReserva.getText());
        String idHabitacion = this.sIdHabitacion.getText();
        Double monto = Double.parseDouble(this.sMonto.getText());
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd/MM/yyyy");
        Date fechaInicio = this.sFechaInicio.getDate();
        Date fechaFin = this.sFechaFin.getDate();
        String Inicio = fechaFormato.format(fechaInicio);
        String Fin = fechaFormato.format(fechaFin);
        resultado = this.control.actualizarReserva(cedulaCliente, idHabitacion, Inicio, Fin, idReserva, monto);
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Reserva " + idReserva + " actualizado con exito", "Actualizado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }// TODO add your handling code here:
    }//GEN-LAST:event_jButton2ActionPerformed

    private void tablaReservasKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaReservasKeyReleased
        int row = this.tablaReservas.getSelectedRow();
        Integer idReserva = (Integer) this.tablaReservas.getModel().getValueAt(row, 1);
        try {
            this.mostrarReserva(idReserva);
        } catch (ParseException ex) {
            Logger.getLogger(VentanaOperacionesReserva.class.getName()).log(Level.SEVERE, null, ex);
        }// TODO add your handling code here:
    }//GEN-LAST:event_tablaReservasKeyReleased

    private void tablaReservasMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaReservasMouseReleased
       int row = this.tablaReservas.getSelectedRow();
        Integer idReserva = (Integer) this.tablaReservas.getModel().getValueAt(row, 1);
        try {
            this.mostrarReserva(idReserva);
        } catch (ParseException ex) {
            Logger.getLogger(VentanaOperacionesReserva.class.getName()).log(Level.SEVERE, null, ex);
        } // TODO add your handling code here:
    }//GEN-LAST:event_tablaReservasMouseReleased

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaOperacionesReserva().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBAgregar;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField nCedulaCliente;
    private com.toedter.calendar.JDateChooser nFechaFin;
    private com.toedter.calendar.JDateChooser nFechaInicio;
    private javax.swing.JTextField nIdHabitacion;
    private javax.swing.JTextField nIdReserva;
    private javax.swing.JTextField sCedulaCliente;
    private com.toedter.calendar.JDateChooser sFechaFin;
    private com.toedter.calendar.JDateChooser sFechaInicio;
    private javax.swing.JTextField sIdHabitacion;
    private javax.swing.JTextField sIdReserva;
    private javax.swing.JTextField sMonto;
    private javax.swing.JTable tablaReservas;
    // End of variables declaration//GEN-END:variables

}
